package cn.jekun.web.shop.action;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import cn.jekun.web.shop.bean.ShopBusiness;
import cn.jekun.web.shop.service.BusinessService;


/**
 * 业务查询
 * 
 * @author Mr.Dong
 *
 */
@SuppressWarnings("serial")
public class BusinessAction extends ShopBaseAction {
	private static final String AUTH_SHOP_MY_SECURITY="SHOP_MY_SECURITY";//安全设置
	private List<ShopBusiness> resultParamsList = new ArrayList<ShopBusiness>();
	private List<ShopBusiness> listBusinesstransport = new ArrayList<ShopBusiness>();
	private List<ShopBusiness> listBusinessAccJournal = new ArrayList<ShopBusiness>();
	private List<ShopBusiness> listPayments = new ArrayList<ShopBusiness>();
	public List<ShopBusiness> getListPayments() {
		return listPayments;
	}
	public void setListPayments(List<ShopBusiness> listPayments) {
		this.listPayments = listPayments;
	}
	public List<ShopBusiness> getListBusinesstransport() {
		return listBusinesstransport;
	}
	public void setListBusinesstransport(List<ShopBusiness> listBusinesstransport) {
		this.listBusinesstransport = listBusinesstransport;
	}
	public List<ShopBusiness> getListBusinessAccJournal() {
		return listBusinessAccJournal;
	}
	public void setListBusinessAccJournal(List<ShopBusiness> listBusinessAccJournal) {
		this.listBusinessAccJournal = listBusinessAccJournal;
	}
	public List<ShopBusiness> getResultParamsList() {
		return resultParamsList;
	}
	public void setResultParamsList(List<ShopBusiness> resultParamsList) {
		this.resultParamsList = resultParamsList;
	}

	private ShopBusiness shopBusiness;
	public ShopBusiness getShopBusiness() {
		return shopBusiness;
	}
	public void setShopBusiness(ShopBusiness shopBusiness) {
		this.shopBusiness = shopBusiness;
	}

	private String beginDate;   //开始日期
	private String endDate;     //结束日期
	private String orderResult; //订单状态
	private String busiType;    //业务类型
	private String paymentType; //资金渠道
	private String keyRange;    //关键词类型
	private String keyword_s;   //关键词
	private String beginMoney;
	private String endMoney;
	public String getBeginMoney() {
		return beginMoney;
	}
	public void setBeginMoney(String beginMoney) {
		this.beginMoney = beginMoney;
	}
	public String getEndMoney() {
		return endMoney;
	}
	public void setEndMoney(String endMoney) {
		this.endMoney = endMoney;
	}
	public String getBeginDate() {
		return beginDate;
	}
	public void setBeginDate(String beginDate) {
		this.beginDate = beginDate;
	}
	public String getEndDate() {
		return endDate;
	}
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
	public String getOrderResult() {
		return orderResult;
	}
	public void setOrderResult(String orderResult) {
		this.orderResult = orderResult;
	}
	public String getBusiType() {
		return busiType;
	}
	public void setBusiType(String busiType) {
		this.busiType = busiType;
	}
	public String getPaymentType() {
		return paymentType;
	}
	public void setPaymentType(String paymentType) {
		this.paymentType = paymentType;
	}
	public String getKeyRange() {
		return keyRange;
	}
	public void setKeyRange(String keyRange) {
		this.keyRange = keyRange;
	}
	public String getKeyword_s() {
		return keyword_s;
	}
	public void setKeyword_s(String keyword_s) {
		this.keyword_s = keyword_s;
	}

	@Resource(name=BusinessService.BEAN_NAME)
	BusinessService busiService;

	@SuppressWarnings("unchecked")
	public String getBusinessDetails(){
		formMap.put("beginDate", beginDate);
		formMap.put("endDate",endDate);
		formMap.put("busiType", busiType); 
		formMap.put("orderResult",orderResult);
		formMap.put("paymenttype", paymentType); 
		formMap.put("keyRange", keyRange); 
		formMap.put("keyword_s", keyword_s); 
		formMap.put("shopId", this.getSessionUser().getShopId());
		formMap.put("beginMoney", beginMoney);
		formMap.put("endMoney", endMoney);
		//判断是否有操作权限
	    this.checkRight(AUTH_SHOP_MY_SECURITY);
		try {
			this.resultList = this.busiService.getBusinessDetails(formMap,page);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "/shop/businessquery.jsp";
		
	}
	
	@SuppressWarnings("unchecked")
	public String getBusinessDetailsById(){
		//判断是否有操作权限
	    this.checkRight(AUTH_SHOP_MY_SECURITY);
		try {
			String businessId = request.getParameter("businessId"); //业务流水号
			formMap.put("shopId", this.getSessionUser().getShopId());
			formMap.put("businessJourNalId", businessId);
			this.shopBusiness = this.busiService.getBusinessDetailsById(formMap);
			this.resultParamsList = this.busiService.getBusinessParamsById(formMap);
			this.listPayments = this.busiService.list("ACTION_BUSINESS_JOURNAL.busipaymentbyId",formMap);
			this.listBusinesstransport = this.busiService.list("ACTION_BUSINESS_JOURNAL.busitransportbyId",formMap);
			this.listBusinessAccJournal = this.busiService.list("ACTION_BUSINESS_JOURNAL.busiaccountjourbyId",formMap);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "/shop/businessdetails.jsp";
	}

}
